<?php
/**
 * 文章增加保存功能
 *
 *
 **/
//获取文章数据
$articleTitle=$_POST['article_title'];
$categoryId= $_POST['category_id'];
$intro= $_POST['intro'];
$articleContent=$_POST['article_content'];

//保存到数据库
date_default_timezone_set("PRC");

$dsn="mysql:Server=127.0.0.1;dbname=blog";
$db= new PDO($dsn, "root", "123456");
$db ->exec("set names utf8mb4");

$addTime =time();
$updateTime =$addTime;

$sql ="insert into article (article_title, category_id, intro, article_content,update_time, add_time)
        values ('$articleTitle', '$categoryId', '$intro', '$articleContent', '$updateTime', '$addTime')";
$result =$db->exec($sql);

if($result){
    echo "增加成功。<a href='article_list.php'>返回列表页面</a>";
    exit();
}else{
    echo "增加失败，错误信息。请联系管理人员：1974289078@qq.com";
}
